<?php
/**
 * Class Order
 * Desc  订单Model
 * Create on 2022/10/13 8:56
 * Create by wangyafang
 */

namespace app\api\model\wdsxh\mall;

use think\Model;
use traits\model\SoftDelete;

class Order extends Model
{
    use SoftDelete;
    protected $deleteTime = 'deletetime';
    // 表名
    protected $name = 'wdsxh_mall_order';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    protected $createTime = 'createtime';

    protected $updateTime = false;

    public function getGoodsAttr($value,$data)
    {
        $cart_ids_array = explode(',',$data['cart_ids']);
        $cartWhere['cart.id'] = array('in',$cart_ids_array);
        $data = Cart::onlyTrashed()->alias('cart')
            ->where($cartWhere)
            ->join('wdsxh_mall_goods goods','goods.id = cart.goods_id')
            ->field('goods.image goods_image,goods.name goods_name')
            ->select();
        foreach ($data as &$v) {
            $v['goods_image'] = wdsxh_full_url($v['goods_image']);
        }
        return $data;
    }


}



 